<template>
  <div class="person-card">
    <el-container>
      <el-aside width="15vw">
        <div class="person-avatar">
          <img :src="avatar" @click="viewPerson"/>
        </div>
      </el-aside>
      <el-main>
        <div class="person-info">
          <a class="person-link" @click="viewPerson">{{ person.fullname }}</a>
          <span v-if="person.othernames">别号： {{ person.othernames }}</span>
          <span class="person-toolbar">
            <ri i="edit" @click="editPerson"></ri>
          </span>
        </div>
        <div class="person-intro">{{ person.intro }}</div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  props: ["person"],
  computed: {
    avatar() {
      return 'https://song.gushiwen.cn/authorImg/dufu.jpg';
    }
  },
  methods: {
    viewPerson() {
      let id = this.person.id;
      this.$router.push("/people/view/" + id);
    },
    editPerson() {
      let id = this.person.id;
      this.$router.push("/people/authors/edit/" + id);
    },
  },
};
</script>

<style lang="stylus" scoped>
.person-card
  border 1px solid #eee
  border-radius 5px
  padding 20px
  margin-bottom 20px
  min-height 150px

  .person-avatar
    height 150px
    width 105px
    margin-right 20px

    img
      cursor pointer
      height 150px
      width 105px

  .person-info
    margin-bottom 10px

    .person-link
      font-weight bold
      font-size 1.2em
      margin-right 20px

    .person-toolbar
      float right

      .icon-button
        color #409EFF
        cursor pointer
</style>